<template>
	<div class="mine-container">
		<div class="bg"></div>
		<!-- <image class="vein" src="http://cdn.rzico.com/v4.0/mine-bg.png"></image> -->
		<list>
			<cell>
				<div :style="{height:statusBarHeight + 'px'}"></div>
				<div class="mine" style="margin-top: 30px;">
					<div class="mine-top">
						<div class="mine-top-info flex" @click="toUserInfo">
							<div class="flex" v-if="noToken">
								<div class="mine-top-head_box">
									<image class="mine-top-head" :src="avatar"></image>
								</div>
								<div class="mine_app">
								<text class="mine-top-name">{{nickName}}</text>
								<text v-if="promoterName" class="mine-top-promoterName">推荐人：{{promoterName}}</text>
								</div>
							</div>
							<!--<div class="mine-top-vip">-->
								<!--<text class="mine-top-vip-inner">vip{{vip}}</text>-->
							<!--</div>-->
						</div>
						<!--<div class="mine-top-sao" @click="openScaner">-->
							<!--<text class="istitle2">&#xe633;</text>-->
						<!--</div>-->
					</div>
<!--					<div class="mine-browse flex">-->
<!--						<div class="mine-browse-favorite" @click="toFavorite">-->
<!--							<div>-->
<!--								<text class="mine-browse-text">{{ favoriteNum != null ?favoriteNum:'0' }}</text>-->
<!--							</div>-->
<!--							<text class="mine-browse_title">收藏夹</text>-->
<!--						</div>-->
<!--						<div class="mine-browse-footprint" @click="toFootprint">-->
<!--							<div>-->
<!--								<text class="mine-browse-text">{{ footprint }}</text>-->
<!--							</div>-->
<!--							<text class="mine-browse_title">足迹</text>-->
<!--						</div>-->
<!--						<div class="mine-browse-address" @click="toCoupon">-->
<!--							<div>-->
<!--								<text class="mine-browse-text">{{ couponNum }}</text>-->
<!--							</div>-->
<!--							<text class="mine-browse_title">优惠券</text>-->
<!--						</div>-->
<!--					</div>-->
          <wallet :time="times"></wallet>
          <div style="margin-left: 30px;margin-top: 20px;border-radius:16px" class="image-wrap" @click="shareClick">
            <image style="height:130px;width:690px;border-radius:16px" src="https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/images/1321321_20211228163812.jpg" ></image>
          </div>
          <functionsAndTasks :time="times"></functionsAndTasks>
          <order :time="times"></order>

<!--					<div class="mine-list bs">-->
<!--						<div class="mine-list-item" @click="goToProduct(15)">-->
<!--							<div class="mine-list-right">-->
<!--								<text class="mine-list-icon"></text>-->
<!--								<text class="mine-list-item-title">惠民站点入驻</text>-->
<!--							</div>-->
<!--							<text class="title2">&#xe61f;</text>-->
<!--						</div>-->
<!--						<div class="mine-list-item" @click="goToProduct(16)">-->
<!--							<div class="mine-list-right">-->
<!--								<text class="mine-list-icon"></text>-->
<!--								<text class="mine-list-item-title">区县代理申请</text>-->
<!--							</div>-->
<!--							<text class="title2">&#xe61f;</text>-->
<!--						</div>-->
<!--						<div class="mine-list-item" @click="goToProduct(17)">-->
<!--							<div class="mine-list-right">-->
<!--								<text class="mine-list-icon"></text>-->
<!--								<text class="mine-list-item-title">市级代理申请</text>-->
<!--							</div>-->
<!--							<text class="title2">&#xe61f;</text>-->
<!--						</div>-->
<!--						<div class="mine-list-item" @click="goToProduct(18)">-->
<!--							<div class="mine-list-right">-->
<!--								<text class="mine-list-icon"></text>-->
<!--								<text class="mine-list-item-title">省级代理申请</text>-->
<!--							</div>-->
<!--							<text class="title2">&#xe61f;</text>-->
<!--						</div>-->


						<!--<div class="mine-list-item" @click="toQuestion">-->
							<!--<div class="mine-list-right">-->
								<!--<text class="mine-list-icon">&#xe613;</text>-->
								<!--<text class="mine-list-item-title">常见问题</text>-->
							<!--</div>-->
							<!--<text class="title2">&#xe61f;</text>-->
						<!--</div>-->
						<!--<div class="mine-list-item" @click="toUs">-->
							<!--<div class="mine-list-right">-->
								<!--<text class="mine-list-icon">&#xe63f;</text>-->
								<!--<text class="mine-list-item-title">关于我们</text>-->
							<!--</div>-->
							<!--<text class="title2">&#xe61f;</text>-->
						<!--</div>-->
<!--					</div>-->


<!--					<div class="mine-server" @click="toCall">-->
<!--						<div class="mine-server-top">-->
<!--							<text class="mine-server-item">鄂公网安备:42082202000090号 </text>-->
<!--						</div>-->
<!--						<div>-->
<!--							<text class="mine-server-item">鄂ICP备:2021002381号-3</text>-->
<!--						</div>-->
<!--					</div>-->
          <!--<div class="mine-server"  @click="toBeian">-->
            <!--<div class="mine-server-top">-->
              <!--<text class="mine-server-item">鄂ICP备2021002381号-3 </text>-->
            <!--</div>-->
            <!--<div  class="mine-server-bottom" @click="toBeian">-->
              <!--<div>-->
                <!--<image style="width:30px;height: 30px;" src="https://www.qmin365.cn/addons/ewei_shopv2/static/images/ga.png"></image>-->
              <!--</div>-->
              <!--<div style="margin-left: 10px">-->
                <!--<text class="mine-server-item">鄂公网安备 42082202000090号</text>-->
              <!--</div>-->
            <!--</div>-->
          <!--</div>-->


					<!--<div class="mine-server" @click="toCall">-->
						<!--<div class="mine-server-top">-->
							<!--<text class="mine-server-item">点击拨打客服热线: </text>-->
							<!--<text class="mine-server-mobile">{{ mch.phone }}</text>-->
						<!--</div>-->
						<!--<div>-->
							<!--<text class="mine-server-item">服务时间：工作日9：00-20：00</text>-->
						<!--</div>-->
					<!--</div>-->
					<div class="gap"></div>
				</div>
			</cell>
		</list>
	</div>
</template>
<script>
    const eeui = app.requireModule('eeui');
	const communication = app.requireModule("eeui/communication");
    import wallet from '../../components/wallet/wallet.vue'
	import order from '../../components/myOrder/myOrder.vue';
	import functionsAndTasks from '../../components/functionsAndTasks/functionsAndTasks.vue';
	import {getInfo} from '../../api/member';
	import {couponCount} from '../../api/coupon';
	import {traceCount} from '../../api/trace';
	import {favoritesCount} from '../../api/favorite';
	import {getInfo as mchGetInfo} from '../../api/enterprise';
	import {list} from '../../api/coupon'
	import {unReadCount} from '../../api/msgPush';
	import {scaner} from '../../api/scan'
	export default {
		pageMessage: function(data) {
			console.log('接收到的信息：', data.message);
			if (data.message.key == 'mine' && this.getGlobalData().token != null) {
				this.getunReadCount()
				this.times = new Date().getTime()
			}
		},
		components: {
      wallet,
			order,
      functionsAndTasks
		},
		data() {
			return {
				promoterName:"",
				noToken: true,
				haveAvatarUrl: false,
				name: '',
				vip: '',
				favoriteNum: 0, //收藏数
				footprint: 0, //足迹
				couponNum: 0, //优惠券数量
				avatar:null, //头像链接
				unReadNum: 0, //未读消息数
				showUnReadNum: '', //显示的未读数量
				mobile: '',
				mch: {
				    logo: null,
					phone: "4008001389"
				},
				statusBarHeight: eeui.getStatusBarHeightPx(),
				nickName: '注册/登陆',
				times: '',
				shareURL:""
			};
		},
		mounted() {
			this.init()
		},
		pageResume() {
			this.init()
			},
		created () {
			this.initIconFont()
		},

		methods: {
      shareClick(){
        if (this.getGlobalData().token == null) {
          eeui.toast('请先登录')
          return;
        }
        eeui.openPage({
          url: 'root://pages/member/share/index.js',
          statusBarType: 'immersion',
          statusBarStyle: false
        }, result => {
          if (result.status == 'stop') {

          }
        });
      },
      toBeian(){
        eeui.openPage({
          params:{url:'https://beian.miit.gov.cn/'},
          url: 'root://pages/webview.js',
          statusBarType: 'immersion',
          statusBarStyle: false
        })
      },
	     openScaner() {
                eeui.openScaner({}, (res)=>{
                    switch (res.status) {
                        case "success":
							this.shareURL=res.text
							if(!this.isNull(this.shareURL)){
								scaner({q:this.shareURL}).then(res=>{
									if(res.type='success'){
									eeui.toast("识别成功");
									}else{
										eeui.toast("识别失败");
									}
								})
							}
                            break;
                    }
                });
            },
			init() {
				if (this.getGlobalData().token != null) {
					this.getTraceCount()
					this.getFavoritesCount()
					this.getCouponData()
					this.getInfo()
					this.getunReadCount()
					this.getInfoClick()
                    this.times = new Date().getTime();
                }
			},
			toGiftCard() {
				eeui.openPage({
					url: 'root://pages/member/giftCard/giftCard.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				})
			},
			getCouponData() {
				list({
					pageSize: 1000
				}).then(res => {
					this.couponNum = res.data.data.length
				})
			},
			toFavorite() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;

				}
				const eeui = app.requireModule('eeui');
				eeui.openPage({
						url: 'root://pages/member/favorite/favorite.js',
						statusBarType: 'immersion',
						statusBarStyle: false
					},
					(result) => {
						if (result.status == 'stop') {
							this.getunReadCount()
							this.times = new Date().getTime()
						}
					}
				);
			},
			toFootprint() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;

				}
				const eeui = app.requireModule('eeui');
				eeui.openPage({
						url: 'root://pages/member/footprint/footprint.js',
						statusBarType: 'immersion',
						statusBarStyle: false
					},
					(result) => {
						if (result.status == 'stop') {
							this.getunReadCount()
							this.times = new Date().getTime()
						}
					}
				);
			},
            goToProduct(data) {
                if (this.getGlobalData().token == null) {
                    this.toPersonInfo()
                    return;

                }
                const eeui = app.requireModule('eeui');
                eeui.openPage({
                        params: data,
                        url: 'root://pages/goods/product/details.js',
                        statusBarType: 'immersion',
                        statusBarStyle: false
                    },
                    (result) => {

                    }
                );
			},
			toCoupon() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;

				}
				const eeui = app.requireModule('eeui');
				eeui.openPage({
						url: 'root://pages/member/coupon/coupon.js',
						statusBarType: 'immersion',
						statusBarStyle: false
					},
					(result) => {
						if (result.status == 'stop') {
							this.getunReadCount()
							this.times = new Date().getTime()
						}
					}
				);
			},
			messageClick() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;

				}
				const eeui = app.requireModule('eeui');
				eeui.openPage({
						url: 'root://pages/member/message/index.js',
						statusBarType: 'immersion',
						statusBarStyle: false
					},
					(result) => {
						if (result.status == 'stop') {
							this.getunReadCount()
							this.times = new Date().getTime()
						}
					}
				);
			},
			getTraceCount() {
				traceCount().then(
					res => {
						if (res.type == 'success') {
							this.footprint = res.data
						}
					}
				).catch(error => {
					console.log(error)
				})
			},
			getFavoritesCount() {
				favoritesCount().then(
					res => {
						this.favoriteNum = res.data
					}
				).catch(error => {
					console.log(error)
				})
			},
			toPersonInfo() {
				var _this = this
				if (this.getGlobalData().token == null) {
					const eeui = app.requireModule('eeui');
					eeui.openPage({
							url: 'root://pages/login/msgLogin.js',
							statusBarType: 'immersion',
							statusBarStyle: false
						},
						(result) => {
							if (result.status == 'stop') {
								if (_this.getGlobalData().token != null) {
									this.getunReadCount()
									this.times = new Date().getTime()
									this.getFavoritesCount()
									this.getTraceCount()
									this.getCouponData()
								}
							}
						}
					);
				}
			},
			// 推广中心
			toShareCenter(e) {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;

				}
				eeui.openPage({
					url: 'root://pages/member/shareCenter/shareCenter.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
					}
				});
			},
			toAddress() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;
				}
				eeui.openPage({
					url: 'root://pages/member/address/address.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
					}
				});
			},
			//常见问题
			toQuestion() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;
				}
				eeui.openPage({
					url: 'root://pages/member/commonProblem/commonProblem.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
					}
				});
			},
			//常见问题
			toPhoneBIll() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;
				}
				eeui.openPage({
					url: 'root://pages/member/phoneBill/phoneBill.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
					}
				});
			},

			//跳转到订单列表
			toPhoneBIllOrderList() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;
				}
				eeui.openPage({
					url: 'root://pages/member/phoneBill/phoneBillOrderList.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					console.info("跳转到订单列表的result-*---------------")
					console.info(result)
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
					}
				});
			},

			//关于我们
			toUs() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;
				}
				eeui.openPage({
					url: 'root://pages/member/aboutUs/aboutUs.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
					}
				});
			},
			//获取用户信息
			getInfo() {
				console.log(this.getGlobalData().userInfo)
				getInfo().then(
					res => {
						console.log("接收用户信息--" + JSON.stringify(res))
						if (res.type == 'success') {
							this.nickName = res.data.member.name;
							this.vip = res.data.member.vip
							this.mobile = res.data.member.mobile
							this.promoterName = res.data.promoterName
							if (!this.isNull(res.data.member.avatar)) {
								this.avatar = this.thumbnail(res.data.member.avatar, 100, 100)
							} else {
								this.avatar = this.mch.logo
//								this.avatar = 'http://cdnx.hulu.fj.cn/00/00/rBD_P13JAWCASx16AAAbC4KUH28426.png'
							}
						}
					}
				).catch(error => {
					console.log(error)
				})
			},
			//获取用户未读信息数量
			getunReadCount() {
				if (this.getGlobalData().token == null) {
					return
				}
				unReadCount().then(
					res => {
						console.log("接收用户信息--" + JSON.stringify(res))
						if (res.type == 'success') {
							let unReadNum = 0
							if (res.data.length > 0) {
								res.data.map(item => {
									unReadNum += item.msg_num
								})
							}
							this.unReadNum = unReadNum
							this.showUnReadNum = unReadNum > 100 ? '...' : unReadNum

						}
					}
				).catch(error => {
					console.log(error)
				})
			},
			toUserInfo() {
				if (this.getGlobalData().token == null) {
					this.toPersonInfo()
					return;
				}
				eeui.openPage({
					url: 'root://pages/member/setUp/setUp.js',
					statusBarType: 'immersion',
					statusBarStyle: false
				}, result => {
					if (result.status == 'stop') {
						this.getunReadCount()
						this.times = new Date().getTime()
						this.getInfo()
					}
				});
			},
			getInfoClick() {
				mchGetInfo().then(res => {
					if (res.type == 'success') {
						this.mch = res.data
                        if (this.isNull(this.avatar)) {
                            this.avatar = this.mch.logo
                        }
					}
				}).catch(error => {
					console.log(error)
				})
			},
			toCall() {
				console.log(this.mch.phone, 'this.mch.phone')
				communication.call(this.mch.phone)
			},
    }
	};
</script>

<style scoped>
	.order {
		height: 130px;
		margin-top: 30px;
	}

	.flex {
		flex-direction: row;
		align-items: center;
	}

	.mine-container {
		position: relative;
		background-color: rgba(248, 248, 248, 1);
	}

	.bg {
		position: absolute;
		left: 0;
		top: 0;
		width: 750px;
		height:500px;
		/* ea706a */
		/* background-image: linear-gradient(to bottom, rgb(194, 194, 194), rgba(248, 248, 248, 1)); */
		/* background-image: linear-gradient(to bottom, rgb(219,98,93), rgb(234,112,106)); */
		  background-image: linear-gradient(to bottom, rgba(236, 95, 88, 1), rgb(252, 147, 147));
	    /* background-image: linear-gradient(to top right, #ea706a, #db625d); */
	}

	.vein {
		position: absolute;
		width: 750px;
		height: 600px;
	}

	.mine {}

	.mine-top {
		margin: 0 30px;
		height: 185px;
		position: relative;
		/*align-items: center;*/
		/* background-color: aquamarine; */
	}

	.mine-top-info {
		position: absolute;
		left: 20px;
		top: 40px;
		align-items: center;
	}
	.mine-top-sao{
		position: absolute;
		right: 20px;
		top: 60px;
		align-items: center;
	}
	.mine-top-head {
		width: 100px;
		height: 100px;
		border-radius: 500px;
	}
	.mine_app{
		display: flex;
		/* background-color: cyan; */

	}
	.mine-top-promoterName{
		margin-top: 20px;
		margin-left: 29px;
		font-size: 28px;
	}

	.mine-top-name {
		margin-left: 29px;
		font-size: 32px;
		font-weight: bold;
		color: rgba(26, 26, 30, 1);
		max-width: 300px;
		lines: 1;
		text-overflow: ellipsis;
	}

	.mine-top-vip {
		margin-left: 15px;
		padding: 2px;
		border-radius: 1px;
		border-color: rgba(194, 172, 126, 1);
		border-width: 1px;
		border-style: solid;
	}

	.mine-top-vip-inner {
		height: 40px;
		padding: 0 15px;
		text-align: center;
		justify-content: center;
		font-size: 20px;
		line-height: 40px;
		font-weight: 400;
		background-color: #c2ac7e;
		opacity: 0.6;
		color: rgba(255, 242, 219, 1);
		text-shadow: 1px 1px 0px rgba(131, 101, 59, 0.2);
	}

	.mine-top-more {
		position: absolute;
		right: 16px;
		top: 94px;
		width: 130px;
		height: 30px;
		font-size: 24px;
		font-weight: 400;
		color: rgba(26, 26, 30, 1);
		opacity: 0.5;
	}

	.mine-top-arrow {
		width: 14px;
		height: 30px;
		position: absolute;
		right: 0px;
		top: 2px;
	}

	/* 第二部分：收藏夹、足迹、收货地址 */

	.mine-browse {
		margin: 0 30px;
		/* height: 115px; */
		padding-top: 15px;
		display: flex;
		font-size: 32px;
		font-weight: 500;
		color: rgba(26, 26, 30, 1);
		align-items: center;
		justify-content: space-around;
	}

	.mine-browse text {
		font-size: 24px;
		font-weight: 400;
		color: rgba(26, 26, 30, 1);
		opacity: 0.5;
	}

	.mine-browse-favorite {
		align-items: center;
		flex-grow: 1;
	}

	.mine-browse-footprint {
		align-items: center;
		flex-grow: 1;
	}

	.mine-browse-address {
		align-items: center;
		flex-grow: 1;
	}

	.mine-browse-text {
		font-size: 30px;
		color: #ffffff;
	}

	/* 第五部分：常见问题、 留言咨询、 消息通知、 系统设置、 关于我们、 */

	.mine-list {
		margin: 40px 30px 0;
		background-color: rgba(255, 255, 255, 1);
		border-radius: 16px;
	}

	.mine-list-item {
		height: 82px;
		position: relative;
		font-size: 28px;
		font-weight: 400;
		color: rgba(26, 26, 30, 1);
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.mine-list-item-title {
		font-size: 28px;
		font-weight: 400;
		color: rgba(26, 26, 30, 1);
		margin-top: 2px;
	}

	.mine-list-right {
		flex-direction: row;
		align-items: center;
	}

	.mine-list-icon {
		font-family: iconfont2;
		font-size: 40px;
		margin: 0 20px;
	}

	.mine-list-arrow {
		width: 50px;
		height: 50px;
		font-size: 50px;
		margin-right: 20px;
		color: #cccccc;
	}

	.mine-contact-button {
		position: absolute;
		height: 82px;
		opacity: 0;
		padding: 0;
		top: 0;
		left: 0;
	}

	.mine-list-num {
		position: absolute;
		right: 70px;
		top: 25px;
		width: 30px;
		height: 30px;
		border-radius: 15px;
		font-size: 20px;
		line-height: 30px;
		text-align: center;
		color: #ffffff;
		background-color: #fc5157;
	}

	/* 第六部分：客服信息 */

	.mine-server {
		margin: 40px 30px 0;
	}

	.mine-server-top {
		flex-direction: row;
		justify-content: center;
	}
.mine-server-bottom{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}
	.mine-server-item {
		text-align: center;
		align-items: center;
		font-size: 28px;
		font-weight: 400;
    color:#ff0000;
    font-size: 30px;
		/*margin-top: 10px;*/
		/*color: rgba(181, 181, 182, 1);*/
	}

	.mine-server-mobile {
		font-size: 20px;
		color: #6782c0;
	}

	.mine-server-item text {
		color: #6782c0;
	}

	/* 底部填充的空白块 */

	.gap {
		height: 50px;
	}


	.title2 {
		font-size: 36px;
		font-family: iconfont2;
		margin: 0 20px;
		color: rgba(26, 26, 30, 1);
		opacity: 0.5;
	}

	.mine-browse_title {
		font-size: 24px;
		font-weight: 400;
		color: rgba(255,255,255, 1);
		/* color: #ffffff; */
		/* opacity: 0.5; */
		margin-top: 10px;
	}

	.mine-top-head_box {
		width: 110px;
		height: 110px;
		border-radius: 500px;
		overflow: hidden;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		background-color: white;
	}
	.istitle2 {
      font-size: 60px;
      font-family: iconfont2;
      color:	#FFA500;
 }
</style>
